home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6743 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  34 lines

  1. Path: sun001.spd.dsccc.com!spd!jmccarty
  2. From: jmccarty@spd.dsccc.com (Mike McCarty)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Easiest way to center a string?
  5. Date: 14 Feb 1996 19:56:18 GMT
  6. Organization: DSC Communications Corporation, Plano, Texas USA
  7. Message-ID: <4ftep2$b8q@sun001.spd.dsccc.com>
  8. References: <4fobka$1st@parlor.hiwaay.net> <4frji4$gbl@gryphon.phoenix.net>
  9. NNTP-Posting-Host: aplo139.spd.dsccc.com
  10.  
  11. In article <4frji4$gbl@gryphon.phoenix.net>,
  12. Bruce Wedding <brucew@phoenix.net> wrote:
  13. )
  14. )>  I'm learning C, and one of my assignments requires that the output strings be
  15. )>centered on the screen. Is there a simple way of doing this that I have overlooked?
  16. )
  17. )Get the length of your string / 2, subtract it from the width of
  18. )your screen / 2.  That is your starting point.  Simple
  19. )
  20. )
  21. )Bruce D. Wedding                        Have Compiler, Will Travel!
  22. )              Perspicacious Programming Performed Promptly
  23. )Katy, Texas, USA, Planet Earth, Milkyway Galaxy, Known Universe
  24.  
  25. Until you get a string too long. Then your screen is messed up.
  26.  
  27. Mike
  28.  
  29.  
  30. ----
  31. char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
  32.  
  33. I don't speak for DSC.         <- They make me say that.
  34.